package com.sservice.commonBusiness.controller.admin;

import com.sservice.base.entity.dto.BaseResult;
import com.sservice.base.entity.dto.ListResult;
import com.sservice.commonBusiness.e.DataR;
import com.sservice.commonBusiness.service.DataRService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * Created by byte_su@163.com on 2018/01/12.
 */
@Controller
@RequestMapping("/admin/dataR/")
public class DataRController {

    @Autowired
    DataRService dataRService;

    @RequestMapping("/delete")
    @ResponseBody
    public BaseResult list(DataR dataR) {
        if (!StringUtils.isNoneBlank(dataR.getType1())) {
            return new BaseResult(false, "参数错误，未指定关系类型", 403);
        }
        dataRService.delBy(dataR);
        return new BaseResult(true, 0);
    }
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @ResponseBody
    public BaseResult add(DataR dataR) {
        dataRService.insertSelective(dataR);
        return new BaseResult(true, 0);
    }
    //
    @RequestMapping(value = "/queryBy",method = RequestMethod.GET)
    @ResponseBody
    public ListResult queryBy(DataR dataR) {
        return new ListResult(true, dataRService.queryBy(dataR));
    }
}
